home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3169 < prev    next >
Encoding:
Text File  |  1996-08-06  |  912 b   |  49 lines

  1. Path: sn.no!usenet
  2. From: larsit@sn.no (Lars-Inge Tonnessen)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Getting the system time and date
  5. Date: Mon, 22 Jan 1996 16:24:52 GMT
  6. Organization: SN Internett
  7. Message-ID: <4e0dm2$pv4@hasle.sn.no>
  8. References: <tate.1.002C7F92@netwest.com>
  9. NNTP-Posting-Host: stavanger2-ppp13.oslo.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. tate@netwest.com (Tate Griffin) wrote:
  13.  
  14. >How do I get the current time and date from a PC using C++?
  15.  
  16.  
  17. You can use a lib that is called "time.h".  Your compiler should
  18. contain it, as it's standard ANSI C.
  19.  
  20.  
  21.  
  22. // Example by Lars-Inge Tonnessen 1996
  23.  
  24. #include <time.h>
  25.     .
  26.     .
  27.     .
  28.  
  29. void main(void)
  30. {
  31.  
  32. tm Times;
  33. cout <<asctime(&Times);
  34.  
  35. }
  36.  
  37.  
  38. When you run the application, it should return:
  39.  
  40. Sun  Jan  21  21:25:16  1996
  41.  
  42. Take a look at the "time.h" file.  It contains allmost everything that
  43. has to do with the time and date.
  44.  
  45. Lars-Inge Tonnessen
  46. larsit@sn.no
  47.  
  48.  
  49.